<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>

	<style type="text/css">
.ui-layout-north {
	z-index: 20 !important;
	overflow: visible !important;;
}

.ui-layout-north .ui-layout-unit-content {
	overflow: visible !important;
}

.ui-widget {
	font-size: 10px !important;
}

.size {
	width: 550px;
	position: relative;
	left: 30%;
	top: 10%;
}

.centro {
	top: 50%
}

.tabela {
	width: 750px;
}
</style>


	<title>Caixa</title>
</h:head>

<h:body>
	<ui:decorate template="/templateBase.xhtml">

		<ui:define name="center">
			<h:form prependId="true" id="formLancamento">
				<br />
				<br />
				<br />
				<br />
				<p:panel header="Caixa - Registrar Baixa" styleClass="size"
					toggleable="true"
					footer="SIGLAS - Sistema de Gerenciamento de Laboratório de Análise de Solo">
					<p:growl id="growl" life="3000" />
					<br />
					<br />
					<h:panelGrid columns="3">
						<h:outputText value="Código Lançamento: " />
						<p:inputText size="10" required="true" disabled="true"
							requiredMessage="Informe a solicitação!"
							value="#{LancamentoBacking.codigoLancamento}" />
						<p:commandButton icon="ui-icon-search"
							oncomplete="dlgLancamento.show()"
							actionListener="#{LancamentoBacking.criaListaLancamento}"
							update=":formPesquisa:tabelaLancamento" process="@all"
							immediate="true" />
					</h:panelGrid>

					<h:panelGrid columns="2">
						<h:outputText value="Solicitante:" />
						<p:inputText size="40" disabled="true"
							value="#{LancamentoBacking.nomeSolicitante}" />
						<h:outputText value="Data do Vencimento: " />
						<p:calendar size="10" disabled="true"
							value="#{LancamentoBacking.dataVencimento}" />
						<h:outputText value="Data do Pagamento: " />
						<p:calendar size="10" value="#{LancamentoBacking.dataPagamento}"
							required="true" requiredMessage="Informe a data de pagamento!" />
						<h:outputText value="Espécie: " />

						<p:selectOneMenu required="true"
							value="#{LancamentoBacking.especie}"
							requiredMessage="Informe a espécie do valor recebido!">
							<f:selectItem itemDisabled="true" itemLabel="Selecione" />
							<f:selectItem itemLabel="Dinheiro" itemValue="Dinheiro" />
							<f:selectItem itemLabel="Cheque" itemValue="Cheque" />
							<f:selectItem itemLabel="Cartão de Crédito"
								itemValue="Cartão de Crédito" />
							<f:selectItem itemLabel="Cartão de Débito"
								itemValue="Cartão de Débito" />
						</p:selectOneMenu>

						<h:outputText value="Valor Total........(R$): " />
						<p:inputText size="10" required="true" disabled="true"
							value="#{LancamentoBacking.valorTotal}">
							<f:convertNumber currencySymbol="R$" groupingUsed="true"
								maxFractionDigits="2" type="currency" />
						</p:inputText>
						<h:outputText value="Valor Recebido..(R$): " />
						<p:inputText size="10" required="true"
							value="#{LancamentoBacking.valorRecebido}"
							requiredMessage="Informe o valor recebido!">
							<p:ajax event="blur" global="false" async="false" update="troco"
								process="@this" listener="#{LancamentoBacking.calculaTroco}"></p:ajax>

						</p:inputText>
						<h:outputText value="Valor do Troco..(R$): " />
						<p:inputText id="troco" size="10" required="true" disabled="true"
							value="#{LancamentoBacking.valorTroco}">
							<f:convertNumber currencySymbol="R$" groupingUsed="true"
								maxFractionDigits="2" type="currency" />
						</p:inputText>


					</h:panelGrid>
					<br />
					<p:separator />
					<br />
					<div align="center">
						<h:panelGrid columns="4">
							<p:commandButton value="Registrar Baixa" ajax="false"
								action="#{LancamentoBacking.salvar}" update="growl"
								icon="ui-icon-disk" />
							<p:commandButton value="Emitir Recibo" ajax="false"
								action="#{LancamentoBacking.geraRecibo}" update="growl"
								icon="ui-icon-print" onclick="this.form.target='_blank'" />
							<p:commandButton value="Cancelar" action="#" ajax="false"
								icon="ui-icon-cancel" />
						</h:panelGrid>
					</div>
				</p:panel>
			</h:form>

			<h:form prependId="false" id="formPesquisa">
				<p:dialog id="pesquisaLancamento" header="Pesquisa de Lançamentos" appendToBody="true" modal="true"
					widgetVar="dlgLancamento" closable="true" hideEffect="clip"
					showEffect="clip" resizable="false" height="480" width="600">

					<p:dataTable var="l" value="#{LancamentoBacking.listaLancamento}"
						emptyMessage="Nenhum lançamento encontrado!" rows="10"
						paginator="true" id="tabelaLancamento">

						<p:column>
							<div align="center">
								<f:facet name="header">
									<h:outputText value="ID" />
								</f:facet>
								<h:outputText value="#{l.codigo}" />
							</div>
						</p:column>

						<p:column filterBy="#{l.dataVencimento}">
							<div align="center">
								<f:facet name="header">
									<h:outputText value="Data de Vencimento" />
								</f:facet>
								<h:outputText value="#{l.dataVencimento}">
									<f:convertDateTime pattern="dd/MM/yyyy" />
								</h:outputText>

							</div>
						</p:column>

						<p:column filterBy="#{l.solicitacao.pessoa.nome}">
							<f:facet name="header">
								<h:outputText value="Solicitante" />
							</f:facet>
							<h:outputText value="#{l.solicitacao.pessoa.nome}" />
						</p:column>

						<p:column>
							<div align="center">
								<f:facet name="header">
									<h:outputText value="Ações" />
								</f:facet>

								<p:commandButton value="Selecionar"
									action="#{LancamentoBacking.selecionaLancamento(l)}"
									process="@this" update=":formLancamento"
									onclick="dlgLancamento.hide()" />
							</div>
						</p:column>


					</p:dataTable>


				</p:dialog>
			</h:form>


		</ui:define>
	</ui:decorate>
</h:body>
</html>